/*
 * Copyright 2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package blms.services;

import java.io.Serializable;
import java.util.Date;

import blms.domain.League;
import blms.domain.Match;
import blms.domain.User;
import blms.exception.MatchDoesNotExistException;
import blms.exception.ValidationException;

/**
 * This service handles creation, update and deletion of matches. It is a service
 * interface to CRUD operations.
 * 
 * @author Jonhnny Weslley
 * @author Thiago Emmanuel Pereira da Cunha Silva, thiago.manel@gmail.com
 * @version 1.00, 22/04/2008
 * @since 1.0
 */
public interface MatchService {

	/**
	 * Creates and adds a new match for the system.
	 * 
	 * @param league
	 * 
	 * @param winner
	 * 			The winner of the match
	 * @param loser
	 * 			The loser of the match
	 * @param date
	 * 			The associated date of the match.
	 * @param length
	 * 			The length of the match
	 * @param score
	 * 			The score of the match
	 * @param longestRunForWinner
	 * 			The longestRunForWinner of the match
	 * @param longestRunForLoser
	 * 			The longestRunForLoser of the match
	 * 
	 * @return
	 * 			The created <code>Match</code>
	 * @throws ValidationException
	 * 			The creation parameters should follow the <code>Match</code>
	 *          value validation rules
	 */
	Match createMatch(League league, User winner, User loser, Date date,
			int length, int score, int longestRunForWinner,
			int longestRunForLoser) throws ValidationException;

	
	/**
	 * Looks up a match.
	 * 
	 * @param id
	 * @return
	 * @throws MatchDoesNotExistException
	 *             if there is not a match with the id.
	 */
	Match getMatch(Serializable id) throws MatchDoesNotExistException;

	/**
	 * @param match
	 * @throws ValidationException
	 */
	void updateMatch(Match match) throws ValidationException;

	/**
	 * Removes the specified match from the system.
	 * 
	 * @param id
	 *            The id of the match to be removed.
	 *             Could not delete a league operator user.
	 * @throws MatchDoesNotExistException
	 *             if there is not a match with the id parameter.
	 */
	void deleteMatch(Serializable id) throws MatchDoesNotExistException;

	/**
	 * Cleans the internal state, removing all the match.
	 */
	void removeAllMatches();

}
